package com.mine.demo.fun;

import com.mine.demo.entity.Apple;
import com.mine.demo.entity.Fruit;
import com.mine.demo.entity.Mango;
import com.mine.demo.entity.Strawberry;

public class Supermarket {
    private double appleWeight;
    private double strawberryWeight;
    private double mangoWeight;

    public Supermarket(double appleWeight, double strawberryWeight, double mangoWeight) {
        this.appleWeight = appleWeight;
        this.strawberryWeight = strawberryWeight;
        this.mangoWeight = mangoWeight;
    }

    public double calculateTotalCost() {
        Apple apple = new Apple();
        Strawberry strawberry = new Strawberry();
        Mango mango = new Mango();

        double totalCost = apple.calculateTotalPrice(appleWeight)
                + strawberry.calculateTotalPrice(strawberryWeight)
                + mango.calculateTotalPrice(mangoWeight);
        System.out.println("此次购买总价为:"+totalCost);
        // 添加满减活动
        if (totalCost >= 100) {
            System.out.println("价格已满100，减10元");
            totalCost -= 10;
            System.out.println("满100减10元后价格:"+totalCost);
        }

        return totalCost;
    }


}